<?php


abstract class BaseTransactionDataPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'transaction_data';

	
	const CLASS_DEFAULT = 'lib.model.TransactionData';

	
	const NUM_COLUMNS = 25;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'transaction_data.ID';

	
	const STATUS_ID = 'transaction_data.STATUS_ID';

	
	const STATE_ID = 'transaction_data.STATE_ID';

	
	const USER_ID = 'transaction_data.USER_ID';

	
	const CUSTOMER_ID = 'transaction_data.CUSTOMER_ID';

	
	const IP = 'transaction_data.IP';

	
	const RECEIPT_ID = 'transaction_data.RECEIPT_ID';

	
	const ORDER_ID = 'transaction_data.ORDER_ID';

	
	const REQUESTED_AMOUNT_CT = 'transaction_data.REQUESTED_AMOUNT_CT';

	
	const REQUESTED_CURRENCY_CODE = 'transaction_data.REQUESTED_CURRENCY_CODE';

	
	const PAID_AMOUNT_CT = 'transaction_data.PAID_AMOUNT_CT';

	
	const PAID_CURRENCY_CODE = 'transaction_data.PAID_CURRENCY_CODE';

	
	const SIGN_PASSWORD = 'transaction_data.SIGN_PASSWORD';

	
	const TRANSACTION_ID = 'transaction_data.TRANSACTION_ID';

	
	const PROJECT_ID = 'transaction_data.PROJECT_ID';

	
	const PROJECT = 'transaction_data.PROJECT';

	
	const PAYTEXT = 'transaction_data.PAYTEXT';

	
	const RETURNED_SS2 = 'transaction_data.RETURNED_SS2';

	
	const RETURNED_ERROR = 'transaction_data.RETURNED_ERROR';

	
	const RETURNED_STATUS = 'transaction_data.RETURNED_STATUS';

	
	const IS_TEST = 'transaction_data.IS_TEST';

	
	const DATA_JSON = 'transaction_data.DATA_JSON';

	
	const UPDATED_AT = 'transaction_data.UPDATED_AT';

	
	const CREATED_AT = 'transaction_data.CREATED_AT';

	
	const APPROVED_AT = 'transaction_data.APPROVED_AT';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'StatusId', 'StateId', 'UserId', 'CustomerId', 'Ip', 'ReceiptId', 'OrderId', 'RequestedAmountCt', 'RequestedCurrencyCode', 'PaidAmountCt', 'PaidCurrencyCode', 'SignPassword', 'TransactionId', 'ProjectId', 'Project', 'Paytext', 'ReturnedSs2', 'ReturnedError', 'ReturnedStatus', 'IsTest', 'DataJson', 'UpdatedAt', 'CreatedAt', 'ApprovedAt', ),
		BasePeer::TYPE_COLNAME => array (TransactionDataPeer::ID, TransactionDataPeer::STATUS_ID, TransactionDataPeer::STATE_ID, TransactionDataPeer::USER_ID, TransactionDataPeer::CUSTOMER_ID, TransactionDataPeer::IP, TransactionDataPeer::RECEIPT_ID, TransactionDataPeer::ORDER_ID, TransactionDataPeer::REQUESTED_AMOUNT_CT, TransactionDataPeer::REQUESTED_CURRENCY_CODE, TransactionDataPeer::PAID_AMOUNT_CT, TransactionDataPeer::PAID_CURRENCY_CODE, TransactionDataPeer::SIGN_PASSWORD, TransactionDataPeer::TRANSACTION_ID, TransactionDataPeer::PROJECT_ID, TransactionDataPeer::PROJECT, TransactionDataPeer::PAYTEXT, TransactionDataPeer::RETURNED_SS2, TransactionDataPeer::RETURNED_ERROR, TransactionDataPeer::RETURNED_STATUS, TransactionDataPeer::IS_TEST, TransactionDataPeer::DATA_JSON, TransactionDataPeer::UPDATED_AT, TransactionDataPeer::CREATED_AT, TransactionDataPeer::APPROVED_AT, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'status_id', 'state_id', 'user_id', 'customer_id', 'ip', 'receipt_id', 'order_id', 'requested_amount_ct', 'requested_currency_code', 'paid_amount_ct', 'paid_currency_code', 'sign_password', 'transaction_id', 'project_id', 'project', 'paytext', 'returned_ss2', 'returned_error', 'returned_status', 'is_test', 'data_json', 'updated_at', 'created_at', 'approved_at', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'StatusId' => 1, 'StateId' => 2, 'UserId' => 3, 'CustomerId' => 4, 'Ip' => 5, 'ReceiptId' => 6, 'OrderId' => 7, 'RequestedAmountCt' => 8, 'RequestedCurrencyCode' => 9, 'PaidAmountCt' => 10, 'PaidCurrencyCode' => 11, 'SignPassword' => 12, 'TransactionId' => 13, 'ProjectId' => 14, 'Project' => 15, 'Paytext' => 16, 'ReturnedSs2' => 17, 'ReturnedError' => 18, 'ReturnedStatus' => 19, 'IsTest' => 20, 'DataJson' => 21, 'UpdatedAt' => 22, 'CreatedAt' => 23, 'ApprovedAt' => 24, ),
		BasePeer::TYPE_COLNAME => array (TransactionDataPeer::ID => 0, TransactionDataPeer::STATUS_ID => 1, TransactionDataPeer::STATE_ID => 2, TransactionDataPeer::USER_ID => 3, TransactionDataPeer::CUSTOMER_ID => 4, TransactionDataPeer::IP => 5, TransactionDataPeer::RECEIPT_ID => 6, TransactionDataPeer::ORDER_ID => 7, TransactionDataPeer::REQUESTED_AMOUNT_CT => 8, TransactionDataPeer::REQUESTED_CURRENCY_CODE => 9, TransactionDataPeer::PAID_AMOUNT_CT => 10, TransactionDataPeer::PAID_CURRENCY_CODE => 11, TransactionDataPeer::SIGN_PASSWORD => 12, TransactionDataPeer::TRANSACTION_ID => 13, TransactionDataPeer::PROJECT_ID => 14, TransactionDataPeer::PROJECT => 15, TransactionDataPeer::PAYTEXT => 16, TransactionDataPeer::RETURNED_SS2 => 17, TransactionDataPeer::RETURNED_ERROR => 18, TransactionDataPeer::RETURNED_STATUS => 19, TransactionDataPeer::IS_TEST => 20, TransactionDataPeer::DATA_JSON => 21, TransactionDataPeer::UPDATED_AT => 22, TransactionDataPeer::CREATED_AT => 23, TransactionDataPeer::APPROVED_AT => 24, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'status_id' => 1, 'state_id' => 2, 'user_id' => 3, 'customer_id' => 4, 'ip' => 5, 'receipt_id' => 6, 'order_id' => 7, 'requested_amount_ct' => 8, 'requested_currency_code' => 9, 'paid_amount_ct' => 10, 'paid_currency_code' => 11, 'sign_password' => 12, 'transaction_id' => 13, 'project_id' => 14, 'project' => 15, 'paytext' => 16, 'returned_ss2' => 17, 'returned_error' => 18, 'returned_status' => 19, 'is_test' => 20, 'data_json' => 21, 'updated_at' => 22, 'created_at' => 23, 'approved_at' => 24, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/TransactionDataMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.TransactionDataMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = TransactionDataPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TransactionDataPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TransactionDataPeer::ID);

		$criteria->addSelectColumn(TransactionDataPeer::STATUS_ID);

		$criteria->addSelectColumn(TransactionDataPeer::STATE_ID);

		$criteria->addSelectColumn(TransactionDataPeer::USER_ID);

		$criteria->addSelectColumn(TransactionDataPeer::CUSTOMER_ID);

		$criteria->addSelectColumn(TransactionDataPeer::IP);

		$criteria->addSelectColumn(TransactionDataPeer::RECEIPT_ID);

		$criteria->addSelectColumn(TransactionDataPeer::ORDER_ID);

		$criteria->addSelectColumn(TransactionDataPeer::REQUESTED_AMOUNT_CT);

		$criteria->addSelectColumn(TransactionDataPeer::REQUESTED_CURRENCY_CODE);

		$criteria->addSelectColumn(TransactionDataPeer::PAID_AMOUNT_CT);

		$criteria->addSelectColumn(TransactionDataPeer::PAID_CURRENCY_CODE);

		$criteria->addSelectColumn(TransactionDataPeer::SIGN_PASSWORD);

		$criteria->addSelectColumn(TransactionDataPeer::TRANSACTION_ID);

		$criteria->addSelectColumn(TransactionDataPeer::PROJECT_ID);

		$criteria->addSelectColumn(TransactionDataPeer::PROJECT);

		$criteria->addSelectColumn(TransactionDataPeer::PAYTEXT);

		$criteria->addSelectColumn(TransactionDataPeer::RETURNED_SS2);

		$criteria->addSelectColumn(TransactionDataPeer::RETURNED_ERROR);

		$criteria->addSelectColumn(TransactionDataPeer::RETURNED_STATUS);

		$criteria->addSelectColumn(TransactionDataPeer::IS_TEST);

		$criteria->addSelectColumn(TransactionDataPeer::DATA_JSON);

		$criteria->addSelectColumn(TransactionDataPeer::UPDATED_AT);

		$criteria->addSelectColumn(TransactionDataPeer::CREATED_AT);

		$criteria->addSelectColumn(TransactionDataPeer::APPROVED_AT);

	}

	const COUNT = 'COUNT(transaction_data.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT transaction_data.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TransactionDataPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TransactionDataPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = TransactionDataPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TransactionDataPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return TransactionDataPeer::populateObjects(TransactionDataPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			TransactionDataPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = TransactionDataPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TransactionDataPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(TransactionDataPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(TransactionDataPeer::ID);
			$selectCriteria->add(TransactionDataPeer::ID, $criteria->remove(TransactionDataPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(TransactionDataPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TransactionDataPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof TransactionData) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TransactionDataPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(TransactionData $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TransactionDataPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TransactionDataPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(TransactionDataPeer::DATABASE_NAME, TransactionDataPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = TransactionDataPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(TransactionDataPeer::DATABASE_NAME);

		$criteria->add(TransactionDataPeer::ID, $pk);


		$v = TransactionDataPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(TransactionDataPeer::ID, $pks, Criteria::IN);
			$objs = TransactionDataPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseTransactionDataPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/TransactionDataMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.TransactionDataMapBuilder');
}
